package controleur;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import modele.FacadeInitSport;

/**
 * Servlet d'initialisation qui permet de creer les sports et de
 * les stocker en base.
 * De même pour membre et competition qui a servi aux tests
 * 
 */
public class Initialisation extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
	@EJB FacadeInitSport fi;
	
    public Initialisation() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String page=request.getParameter("init");
		
		if(page.equals("sports")){
			fi.sports();
		}
		else if (page.equals("competitions")){
			fi.competitions();
		}
		
		else if (page.equals("membre")){
			fi.membre();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
